package com.arron.juc;

/**
 * @Classname EnumDemo
 * @Description TODO
 * @Date 2020/8/21 14:52
 * @Created by 刘
 */
public enum EnumDemo {

    ONE(1, "齐国"), TWO(2, "楚国"), THREE(3, "韩国"), FOUR(4, "魏国"), FIVE(5, "赵国"), SIX(6, "燕国");

    private Integer code;
    private String name;

    EnumDemo(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static EnumDemo forEachIndex(Integer code) {

        for (EnumDemo demo : EnumDemo.values()) {
            if (demo.getCode() == code) {
                return demo;
            }
        }
        return null;
    }

}
